<script setup>
import { getBannerAPI } from '@/apis/home'
import { onMounted, ref } from 'vue'

const bannerList = ref([])

//定义一个数据列表获取商城网路图片
const bannerlist = ref([
  {
    id: 1,
    imgUrl: 'https://gd-hbimg.huaban.com/22233a3a53de36c21e848df5e94ecdbe1958bae642baa-lojI8U_fw658'
  },
  {
    id: 2,
    imgUrl: "https://img95.699pic.com/photo/40193/6556.jpg_wh300.jpg!/fh/300/quality/90"
  },
  {
    id: 3,
    imgUrl: "https://img95.699pic.com/photo/40031/0571.jpg_wh300.jpg!/fh/300/quality/90"
  }
])
const getBanner = async () => {
  const res = await getBannerAPI()
  bannerList.value = res.data.result
}

onMounted(() => getBanner())

</script>



<template>
  <div class="home-banner">
    <el-carousel height="500px">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <router-link :to="`${item.hrefUrl}`">
          <img :src="item.imgUrl" alt="">
        </router-link>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>



<style scoped lang='scss'>
@media screen and (max-width: 768px) {
  .home-banner {
    display: none !important;
  }
}

.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;

  img {
    position: absolute;
    left: 250px;
    width: calc(100% - 250px);
    height: 500px;
  }
}
</style>